package listeners 
{
	import org.flexunit.runner.notification.Failure;
	import org.flexunit.runner.Result;
	import flash.events.EventDispatcher;
	import org.flexunit.runner.IDescription;
	import org.flexunit.runner.notification.IAsyncStartupRunListener;
	import org.flexunit.runner.notification.ITemporalRunListener;
	
	/**
	 * ...
	 * @author Victor Rosales
	 */
	public class TraceListener extends EventDispatcher implements IAsyncStartupRunListener, ITemporalRunListener 
	{
		
		public function TraceListener() 
		{
			
		}
		
		private function log(... args):void 
		{
			trace("[FlexUnit] " + args.join(","));
		}
		
		
		/* INTERFACE org.flexunit.runner.notification.ITemporalRunListener */
		
		public function testTimed(description:IDescription, runTime:Number):void 
		{
			log("Test timed", description.displayName, runTime);
		}
		
		public function testRunStarted(description:IDescription):void 
		{
			log("Test run started", description.displayName);
		}
		
		public function testRunFinished(result:Result):void 
		{
			log("Test run finished", result);
		}
		
		public function testStarted(description:IDescription):void 
		{
			log("Test started", description.displayName);
		}
		
		public function testFinished(description:IDescription):void 
		{
			log("Test finished", description.displayName);
		}
		
		public function testFailure(failure:Failure):void 
		{
			log("Test failed", failure.toString());
		}
		
		public function testAssumptionFailure(failure:Failure):void 
		{
			log("Test assumption failure", failure.toString());
		}
		
		public function testIgnored(description:IDescription):void 
		{
			log("Test ignored", description.displayName);
		}
		
		/* INTERFACE org.flexunit.runner.notification.IAsyncStartupRunListener */
		
		public function get ready():Boolean 
		{
			return true;
		}
		
	}

}